from django.conf.urls.defaults import *
from django.views.generic import simple
#from django.contrib.syndication import feeds

from best_buy_book.shop.models import *
from feeds import A3B

#### REsT
from django_restapi.model_resource import Collection
from django_restapi.responder import *

xml_libro_resource = Collection(
    queryset = Libro.objects.all(),
    permitted_methods = ('GET', 'POST', 'PUT', 'DELETE'),
    expose_fields = ('titulo', 'isbn', 'keyword__word'), #'autor__first_name''id', 
    responder = XMLResponder(paginate_by = 10)
)

"""
xml_choice_resource = Collection(
    queryset = Choice.objects.all(),
    permitted_methods = ('GET',),
    expose_fields = ('id', 'poll_id', 'choice'),
    responder = XMLResponder(paginate_by = 5)
)

urlpatterns = patterns('',
   
   url(r'^xml/choices/(.*?)/?$', xml_choice_resource)
)
"""


""" #'categories': LatestEntriesByCategory,
urlpatterns = patterns('',
    # ...
    (r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed',
        {'feed_dict': feeds}),
    # ...
)#(r'^shop/feeds/$', 'simple', {'feed_dict': feeds}),

#(r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed',
    #    {'feed_dict': feeds}),

"""



feeds = {
    'lastest': A3B
}

urlpatterns = patterns('',
    url(r'^/?$', simple.direct_to_template, {'template': 'index.html'}),
    url(r'^shop/?$', simple.direct_to_template, {'template': 'index.html'}),
    url(r'^contacto/$', simple.direct_to_template, {'template': 'contacto.html'}),
    url(r'^ayuda/$', simple.direct_to_template, {'template': 'ayuda.html'}),
    url(r'^shop/libros/$', 'best_buy_book.shop.views.listbooks'),
    url(r'^shop/autor/(?P<autor_username>\w+)/$', 'best_buy_book.shop.views.biography'),
    (r'^shop/libro/(?P<libro_isbn>\d+)/$', 'best_buy_book.shop.views.libro'),
    (r'^shop/buscar/$', 'best_buy_book.shop.views.buscar'),
    (r'^shop/correoayuda/$', 'best_buy_book.shop.views.correoayuda'),
    (r'^shop/transmite/$', 'best_buy_book.shop.views.transmitir'),
    (r'^shop/recibe/$', 'best_buy_book.shop.views.recibir'),
    (r'^admin/reporte-ventas', 'best_buy_book.shop.views.reporteventas'),
    (r'^shop/feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds}),
    url(r'^shop/xml/libro/(.*?)/?$', xml_libro_resource),
    (r'^src/(?P<path>.*)$', 'django.views.static.serve', {'document_root': 'src'}),
    (r'^shop/cart/$', 'best_buy_book.shop.views.cart'),
    (r'^shop/cart/add//testcookie/$', 'best_buy_book.shop.views.testcookie'),
    (r'^shop/cart/add/(?P<artnr>.*)/$', 'best_buy_book.shop.views.addtocart'),
    (r'^shop/cart/empty/$', 'best_buy_book.shop.views.emptycart'),
    (r'^shop/cart/updatecart/$', 'best_buy_book.shop.views.updatecart'),
    (r'^shop/cart/comprar/$', 'best_buy_book.shop.views.comprar'),
)
